<template>
  <div class="updataDiv">
    <h3>修改车位信息</h3>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="车位号码">
        <el-input
          v-model="formInline.carNumber"
          placeholder="车位号"
        ></el-input>
      </el-form-item>
      <el-form-item label="修改价格">
        <el-input
          v-model="formInline.price"
          placeholder="价格"
        ></el-input> </el-form-item
      ><br />
      <el-form-item label="产权信息">
        <el-input
          v-model="formInline.property"
          placeholder="产权信息"
        ></el-input>
      </el-form-item>
      <el-form-item label="修改周期">
        <el-select v-model="formInline.cycle" placeholder="出租周期">
          <el-option label="三个月" :value="3"></el-option>
          <el-option label="六个月" :value="6"></el-option>
          <el-option label="九个月" :value="9"></el-option>
          <el-option label="十二个月" :value="12"></el-option>
        </el-select> </el-form-item
      ><br />
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确定修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import axios from "axios";
export default {
  props: ["_id"],
  mounted() {
    this.updataOne();
  },
  data() {
    return {
      formInline: {},
    };
  },
  methods: {
    //修改当前车位
   async onSubmit() {
   const {data} = await axios({
       url:'/xg/inxgPArkings',
       method:"get",
       params:this.formInline
     })
     if(data.status){
        alert(data.message)
        this.$router.go(-1)
     }
    },
    //获取当前车位
    async updataOne() {
      const { data } = await axios({
        url: "/xg/xgparking",
        method: "get",
        params: {
          _id: this._id,
        },
      });
      console.log(data.data);
      this.formInline = { ...data.data };
    },
  },
};
</script>

<style>
.updataDiv {
  text-align: center;
}
h3 {
  margin-bottom: 50px;
}
</style>